﻿@*
//------------------------------------------------------------------------------
//  此代码版权声明为全文件覆盖，如有原作者特别声明，会在下方手动补充
//  此代码版权（除特别声明外的代码）归作者本人Diego所有
//  源代码使用协议遵循本仓库的开源协议及附加协议
//  Gitee源代码仓库：https://gitee.com/diego2098/ThingsGateway
//  Github源代码仓库：https://github.com/kimdiego2098/ThingsGateway
//  使用文档：https://diego2098.gitee.io/thingsgateway-docs/
//  QQ群：605534569
//------------------------------------------------------------------------------
*@

@using BlazorComponent;
@using Microsoft.AspNetCore.Components.Web;
@using Masa.Blazor.Presets;
@using Microsoft.JSInterop;
@using ThingsGateway.Admin.Blazor.Core;
@using ThingsGateway.Application;
@using ThingsGateway.Blazor;
@using ThingsGateway.Foundation;
@using ThingsGateway.Foundation.Adapter.OPCDA.Da;
@using ThingsGateway.Foundation.Extension;
@using ThingsGateway.Foundation.Serial;
@using Masa.Blazor
@using TouchSocket.Core;
@using Yitter.IdGenerator;
<OPCDAClientPage @ref=opcDAClientPage></OPCDAClientPage>
<DefalutDebugDriverPage @ref=defalutDebugDriverPage>
    <OtherContent>
        <MCol Class="my-1 py-1">
            <MRow NoGutters>

                <MButton Class="mx-1 my-3" Color="accent" OnClick="()=>IsShowImportVariableList=!IsShowImportVariableList">
                    <span>导入变量</span>
                </MButton>

            </MRow>
            <MTextField Class="mx-1 my-1" Label="变量地址" Dense Outlined HideDetails="@("auto")" @bind-Value=@defalutDebugDriverPage.Address />
            <MRow NoGutters>
                <MButton Class="mx-1 my-1" Color="primary" OnClick="Add">
                    添加
                </MButton>
                <MButton Class="mx-1 my-1" Color="primary" OnClick="Remove">
                    移除
                </MButton>
            </MRow>

            <MButton Class="mx-1 my-1" Color="primary" OnClick="ReadAsync">
                组读取
            </MButton>
            <MTextarea Class="mx-1 mt-3 my-1" Label="值" Dense Outlined HideDetails="@("auto")" @bind-Value=@defalutDebugDriverPage.WriteValue />
            <MButton Class="mx-1 my-1" Color="primary" OnClick="WriteAsync">
                写入
            </MButton>

        </MCol>
    </OtherContent>
</DefalutDebugDriverPage>

<PModal @bind-Value="IsShowImportVariableList" OnCancel="() => IsShowImportVariableList = false"
        Title=导入OPC变量 Height=@("700") Persistent
        MaxWidth="1500" OnSave="DownDeviceExport">
    <SaveContent Context="save">
        <MMenu OffsetY Context="menu">
            <ActivatorContent>
                <MButton @attributes="@menu.Attrs" Color="primary"
                         Class="my-1  mx-2 ">
                    导出
                    <AppChevronDown></AppChevronDown>
                </MButton>
            </ActivatorContent>
            <ChildContent>
                <MList>
                    <MListItem OnClick="()=>DownDeviceExport()" Disabled="save.Loading" Loading="save.Loading">导出到excel</MListItem>
                    <MListItem OnClick="()=>DeviceImport()" Disabled="save.Loading" Loading="save.Loading">导入到系统</MListItem>
                </MList>

            </ChildContent>
        </MMenu>

    </SaveContent>
    <ChildContent>
        @if (IsShowImportVariableList)
        {
            <ImportVariable @ref=ImportVariable PLC="_plc"></ImportVariable>
        }
    </ChildContent>

</PModal>

